﻿@model IEnumerable<QuizeDto>
@section MainStyle{

    <!-- bradcam_area_start -->
    <div class="bradcam_area breadcam_bg overlay2">
        <h3>Quizes</h3>
    </div>
    <!-- bradcam_area_end -->

}
<div style="text-align:center">
    <h1 class="boxed_btn">Please Refresh Page To Ensure That Quize Is Start</h1>

    <table class="table table-hover mt-5">
        <thead class="thead-dark">
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.Description)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.TimeStart)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.TimeEnd)
                </th>
                <th>Duration</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {

                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.TimeStart)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.TimeEnd)
                    </td>
                    <td>
                        @{
                            var hour = item.Hour?.ToString() ?? "00";
                            var minute = item.Minute?.ToString() ?? "00";
                        }
                        <span style="font-size:16px" class="badge rounded-pill bg-success text-white">@($"{hour}:{minute}")</span>
                    </td>
                    <td>
                        @if (item.TimeStart <= DateTime.Now && DateTime.Now <= item.TimeEnd)
                        {
                            <a class="btn btn-info text-white" asp-action="Details" asp-route-id="@item.Id" title="Do Exam"><i class="fas fa-sign-in-alt"></i></a>
                        }
                        @{var permission = item.GroupPermissions.FirstOrDefault(a => a.UserProfileId == (int)ViewData["UserId"]); }
                        @if (item.UserProfileId == (int)ViewData["UserId"])
                        {
                            <a asp-action="GetStudentsDegrees" asp-controller="Degree" asp-route-quizeId="@item.Id" title="Details" class="btn btn-warning text-white"><i class="fas fa-info-circle"></i></a>
                            <a class="btn btn-info text-white" asp-action="Edit" asp-route-id="@item.Id"><i class="far fa-edit"></i></a>
                            <a class="btn btn-danger" asp-action="Delete" asp-route-id="@item.Id"><i class="fas fa-trash-alt"></i></a>
                        }
                        @if (permission != null && permission.Edit)
                        {
                            <a class="btn btn-info text-white" asp-action="Edit" asp-route-id="@item.Id"><i class="far fa-edit"></i></a>
                        }
                        @if (permission != null && permission.Delete)
                        {
                            <a class="btn btn-danger" asp-action="Delete" asp-route-id="@item.Id"><i class="fas fa-trash-alt"></i></a>
                        }
                    </td>
                </tr>
            }
        </tbody>

    </table>
</div>